<template>
	<view class="my-userinfo-container">
		<view class="top-box">
			<image :src="userinfo.avatarUrl" class="avatar"></image>
			<text class="nickname">{{userinfo.nickName}}</text>
		</view>
		<view class="panel-list">
			<view class="panel">
				<view class="panel-body">
					<view class="panel-item">
						<text>4</text>
						<text>收藏的店铺</text>
					</view>
					<view class="panel-item">
						<text>12</text>
						<text>收藏的商品</text>
					</view>
					<view class="panel-item">
						<text>20</text>
						<text>关注的商品</text>
					</view>
					<view class="panel-item">
						<text>66</text>
						<text>足迹</text>
					</view>
				</view>
			</view>
			<view class="panel">
				<view class="panel-title">
					我的订单
				</view>
				<view class="panel-body">
					<view class="panel-item">
						<image src="/static/icon1.png" class="icon"></image>
						<text>待付款</text>
					</view>
					<view class="panel-item">
						<image src="/static/icon2.png" class="icon"></image>
						<text>待收货</text>
					</view>
					<view class="panel-item">
						<image src="/static/icon3.png" class="icon"></image>
						<text>退款/售后</text>
					</view>
					<view class="panel-item">
						<image src="/static/icon4.png" class="icon"></image>
						<text>全部订单</text>
					</view>
				</view>
			</view>
			<view class="panel">
				<view class="panel-list-item">
					<text>收货地址</text>
					<uni-icons type="arrowright" size="15"></uni-icons>
				</view>
				<view class="panel-list-item">
					<text>联系客服</text>
					<uni-icons type="arrowright" size="15"></uni-icons>
				</view>
				<view class="panel-list-item" @click="logout"> 
					<text>退出登录</text>
					<uni-icons type="arrowright" size="15"></uni-icons>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		name: "my-userinfo",
		data() {
			return {

			};
		},
		computed: {
			...mapState('m_user', ['userinfo'])
		},
		methods:{
			...mapMutations('m_user',['getUserinfo','getAddress','getToken']),
			logout(){
				uni.showModal({
					title:'提示',
					content:'确认退出登录吗?',
					success: (res) => {
						if(res.confirm){
							this.getAddress({})
							this.getToken('')
							this.getUserinfo({})
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.my-userinfo-container {
		height: 100vh;
		background-color: #f4f4f4;

		.top-box {
			height: 400rpx;
			background-color: #c00000;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			color: #fff;
			font-weight: bold;

			.avatar {
				width: 160rpx;
				height: 160rpx;
				border-radius: 50%;
				margin-bottom: 20rpx;
				border: 4rpx solid #fff;
				box-shadow: 0 2rpx 10rpx black;
			}
		}

		.panel-list {
			padding: 0 20rpx;
			position: relative;
			top: -20rpx;

			.panel {
				background-color: #fff;
				border-radius: 10rpx;
				margin-bottom: 16rpx;

				.panel-title {
					padding: 20rpx;
					font-size: 32rpx;
					font-weight: bold;
					border-bottom: 1px solid #efefef;
				}

				.panel-body {
					display: flex;
					justify-content: space-around;

					.panel-item {
						display: flex;
						flex-direction: column;
						align-items: center;
						justify-content: space-around;
						font-size: 26rpx;
						padding: 20rpx 0;

						.icon {
							width: 80rpx;
							height: 80rpx;
						}
					}
				}
				.panel-list-item{
					padding:30rpx 20rpx;
					display: flex;
					justify-content: space-between;
				}
			}
		}
	}
</style>
